var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
/// <reference path="tUnit.ts" />
/// <reference path="app.ts" />
var Int32 = (function () {
    function Int32() { }
    Int32.MAX_VALUE = 0x7FFFFFFF;
    return Int32;
})();
var TriangleTests;
(function (TriangleTests) {
    /** Test functions of tUnit **/
    var tUnitTests = (function (_super) {
        __extends(tUnitTests, _super);
        function tUnitTests() {
            _super.apply(this, arguments);

        }
        tUnitTests.prototype.TestTrue = function () {
            Assert.isTrue(true);
        };
        tUnitTests.prototype.TestFalse = function () {
            Assert.isFalse(false);
        };
        tUnitTests.prototype.TestStringEqual = function () {
            Assert.equal("abc", "ab" + "c");
        };
        tUnitTests.prototype.TestThrows = function () {
            Assert.throws(function () {
                throw "Hey";
            });
        };
        tUnitTests.prototype.TestThrowsButNoException = function () {
            Assert.throws(function () {
            });
        };
        tUnitTests.prototype.TestEqualFloatingNumber = function () {
            Assert.equalNumber(0.1 + 0.2, 0.3);
            Assert.equalNumber((0.1 + 0.2) / 123.3457 * 123.4477, 0.3 / 123.3457 * 123.4477);
        };
        tUnitTests.prototype.TestNotEqualFloatingNumber = function () {
            Assert.notEqualNumber((0.1 + 0.2) / 123.3457 * 123.4477, 0.3000000001 / 123.3457 * 123.4477);
        };
        return tUnitTests;
    })(tUnit.TestClass);
    TriangleTests.tUnitTests = tUnitTests;    
    //SetUp and tearDown should perform for each test.
    var tUnitTestsForSetUp = (function (_super) {
        __extends(tUnitTestsForSetUp, _super);
        function tUnitTestsForSetUp() {
            _super.apply(this, arguments);

            this.i = 1;
        }
        tUnitTestsForSetUp.prototype.setUp = function () {
            this.i++;
        };
        tUnitTestsForSetUp.prototype.tearDown = function () {
            this.i--;
        };
        tUnitTestsForSetUp.prototype.TestI = function () {
            Assert.equal(this.i, 2);
        };
        tUnitTestsForSetUp.prototype.TestI2 = function () {
            Assert.equal(this.i, 2);
        };
        return tUnitTestsForSetUp;
    })(tUnit.TestClass);
    TriangleTests.tUnitTestsForSetUp = tUnitTestsForSetUp;    
    var tUnitTestsForSetUpWithExceptionOnce = (function (_super) {
        __extends(tUnitTestsForSetUpWithExceptionOnce, _super);
        function tUnitTestsForSetUpWithExceptionOnce() {
            _super.apply(this, arguments);

            this.i = 1;
        }
        tUnitTestsForSetUpWithExceptionOnce.prototype.setUp = function () {
            this.i++;
            if (this.i === 2) {
                throw "This is expected. And the setUp exception will be thrown only once. 1 instance expected.";
            }
        };
        tUnitTestsForSetUpWithExceptionOnce.prototype.tearDown = function () {
            this.i--;
        };
        tUnitTestsForSetUpWithExceptionOnce.prototype.TestI = function () {
            Assert.isTrue(this.i > 2);
        };
        tUnitTestsForSetUpWithExceptionOnce.prototype.TestI2 = function () {
            Assert.isTrue(this.i > 2);
        };
        return tUnitTestsForSetUpWithExceptionOnce;
    })(tUnit.TestClass);
    TriangleTests.tUnitTestsForSetUpWithExceptionOnce = tUnitTestsForSetUpWithExceptionOnce;    
    var tUnitTestsForSetUpWithException = (function (_super) {
        __extends(tUnitTestsForSetUpWithException, _super);
        function tUnitTestsForSetUpWithException() {
            _super.apply(this, arguments);

        }
        tUnitTestsForSetUpWithException.prototype.setUp = function () {
            throw "This is expected inside setUp for tUnitTestsForSetUpWithException, so no test in this class will perform. You must not fix this. 2 instances expected";
        };
        tUnitTestsForSetUpWithException.prototype.tearDown = function () {
            Assert.fail();
        };
        tUnitTestsForSetUpWithException.prototype.TestI = function () {
            Assert.fail();
        };
        tUnitTestsForSetUpWithException.prototype.TestI2 = function () {
            Assert.fail();
        };
        return tUnitTestsForSetUpWithException;
    })(tUnit.TestClass);
    TriangleTests.tUnitTestsForSetUpWithException = tUnitTestsForSetUpWithException;    
    var tUnitTestsForTestFixtureSetUpWithException = (function (_super) {
        __extends(tUnitTestsForTestFixtureSetUpWithException, _super);
        function tUnitTestsForTestFixtureSetUpWithException() {
            _super.apply(this, arguments);

        }
        tUnitTestsForTestFixtureSetUpWithException.prototype.testFixtureSetUp = function () {
            throw "This is expected inside setUp for tUnitTestsForSetUpWithException, so no test in this class will perform. You must not fix this. 1 instance expected.";
        };
        tUnitTestsForTestFixtureSetUpWithException.prototype.testFixtureTearDown = function () {
            Assert.fail();
        };
        tUnitTestsForTestFixtureSetUpWithException.prototype.TestI = function () {
            Assert.fail();
        };
        tUnitTestsForTestFixtureSetUpWithException.prototype.TestI2 = function () {
            Assert.fail();
        };
        return tUnitTestsForTestFixtureSetUpWithException;
    })(tUnit.TestClass);
    TriangleTests.tUnitTestsForTestFixtureSetUpWithException = tUnitTestsForTestFixtureSetUpWithException;    
    //testFixtureSetUp and testFixturetearDown should perform once for TestFixture.
    var tUnitTestsForTestFixtureSetUp = (function (_super) {
        __extends(tUnitTestsForTestFixtureSetUp, _super);
        function tUnitTestsForTestFixtureSetUp() {
            _super.apply(this, arguments);

            this.i = 1;
        }
        tUnitTestsForTestFixtureSetUp.prototype.testFixtureSetUp = function () {
            this.i++;
        };
        tUnitTestsForTestFixtureSetUp.prototype.testFixtureTearDown = function () {
            this.i--;
        };
        tUnitTestsForTestFixtureSetUp.prototype.TestI = function () {
            Assert.equal(this.i, 2);
        };
        tUnitTestsForTestFixtureSetUp.prototype.TestI2 = function () {
            Assert.equal(this.i, 2);
        };
        return tUnitTestsForTestFixtureSetUp;
    })(tUnit.TestClass);
    TriangleTests.tUnitTestsForTestFixtureSetUp = tUnitTestsForTestFixtureSetUp;    
    var SimpleTests = (function (_super) {
        __extends(SimpleTests, _super);
        function SimpleTests() {
            _super.apply(this, arguments);

        }
        SimpleTests.prototype.ShouldBeEqual = function () {
            var r = GetTriangleType(100, 100, 100);
            Assert.equal(TriangleType.Equilateral, r);
        };
        SimpleTests.prototype.shouldBeEquilateral = function () {
            Assert.equal(TriangleType.Equilateral, GetTriangleType(100, 100, 100));
        };
        SimpleTests.prototype.shouldBeIsosceles = function () {
            Assert.equal(TriangleType.Isosceles, GetTriangleType(100, 100, 90));
        };
        SimpleTests.prototype.shouldBeScalene = function () {
            Assert.equal(TriangleType.Scalene, GetTriangleType(100, 33, 90));
        };
        SimpleTests.prototype.zeroSideShouldBeError = function () {
            Assert.equal(TriangleType.Error, GetTriangleType(0, 33, 90));
        };
        SimpleTests.prototype.negativeSideShouldBeError = function () {
            Assert.equal(TriangleType.Error, GetTriangleType(-3, 33, 90));
            Assert.equal(TriangleType.Error, GetTriangleType(3, -33, 90));
        };
        SimpleTests.prototype.malformedSidesShouldBeError = function () {
            Assert.equal(TriangleType.Error, GetTriangleType(100, 100, 200));
        };
        SimpleTests.prototype.shouldBeIsoscelesWithMaxValue = function () {
            Assert.equal(TriangleType.Isosceles, GetTriangleType(Int32.MAX_VALUE - 1000, Int32.MAX_VALUE - 1000, Int32.MAX_VALUE));
            Assert.equal(TriangleType.Isosceles, GetTriangleType(Int32.MAX_VALUE, Int32.MAX_VALUE, 1));
        };
        return SimpleTests;
    })(tUnit.TestClass);
    TriangleTests.SimpleTests = SimpleTests;    
    var TestContextHelper = (function () {
        function TestContextHelper() { }
        TestContextHelper.equalNumber = function equalNumber(expected, actual) {
            if (Math.abs(expected - actual) >= 0.0000000000000001) {
                throw 'equal failed when passed ' + '{' + (typeof expected) + '} "' + expected + '" and ' + '{' + (typeof actual) + '} "' + actual + '"';
            }
            return true;
        };
        return TestContextHelper;
    })();    
})(TriangleTests || (TriangleTests = {}));
window.onload = function () {
    var test = new tUnit.Test();
    test.addTestClass(new TriangleTests.SimpleTests(), 'SimpleTests');
    test.addTestClass(new TriangleTests.tUnitTests(), 'tUnitTests');
    test.addTestClass(new TriangleTests.tUnitTestsForSetUp(), 'tUnitTestsForSetUp');
    test.addTestClass(new TriangleTests.tUnitTestsForSetUpWithException(), 'tUnitTestsForSetUpWithException');
    test.addTestClass(new TriangleTests.tUnitTestsForSetUpWithExceptionOnce(), 'tUnitTestsForSetUpWithExceptionOnce');
    test.addTestClass(new TriangleTests.tUnitTestsForTestFixtureSetUp(), 'tUnitTestsForTestFixtureSetUp');
    test.addTestClass(new TriangleTests.tUnitTestsForTestFixtureSetUpWithException(), 'tUnitTestsForTestFixtureSetUpWithException');
    test.showResults(document.getElementById('results'), test.run());
};
//@ sourceMappingURL=Tests.js.map
